<?php

namespace app\datadict\controller;

use think\facade\Config;
use think\Request;
use app\common;
use app\common\Common as CommonCommon;

class Index
{
    /**
     *  index
     */
    public function index(Request $request)
    {
        $param['lang'] = $request->param('lang', null);
        $param['dictname'] = $request->param('dictname', null);
        $DD_PATH = Config::get('app.datadict_path');
        $arrData = array();
        $arrDict = explode(",", $param['dictname']);
        for ($i = 0; $i < count($arrDict); $i++) {
            if (file_exists($DD_PATH . '/' . $param['lang'] . '/' . $arrDict[$i] . '.php')) {
                $arrData[$arrDict[$i]] = include $DD_PATH . '/' . $param['lang'] . '/' . $arrDict[$i] . '.php';
            } else {
                $arrData[$arrDict[$i]] = array();
            }
        }
        return json(['code' => 0, 'message' => '成功', 'data' => $arrData]);
    }
}
